package com.global.college.base;

import android.content.Context;
import androidx.multidex.MultiDexApplication;

import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.imagepipeline.core.ImagePipelineConfig;
import com.global.college.constants.Constant;
import com.global.college.utils.CrashHandlerUtils;
import com.global.college.utils.LangUtils;
import com.global.college.utils.PrefUtils;
import com.global.college.widget.daynight.DayNightHelper;
//import com.tencent.bugly.crashreport.CrashReport;


/**
 * Created by fu on 2021/9/13.
 * Describe: 自定义全局 application 主要进全局引用,行存储全局变量,全局配置/设置,初始化等相关工作
 */
public class BaseApplication extends MultiDexApplication {

    /**
     * 获取全局的Context
     */
    private static Context mContext;
    public static Context getContext() {
        return mContext;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        mContext = getApplicationContext();

        //初始化SharedPreferences
        PrefUtils.init(this);
        DayNightHelper.init(this);
        //全局捕获异常初始化  --  本地上传，目前没有上传
        CrashHandlerUtils.getInstance().init(this);

        // //初始化-腾讯bugly云端收集bug
//        CrashReport.initCrashReport(getApplicationContext(), Constant.TENGXUN_BUGLY_LOG, false);

        //初始化Fresco
        ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
                .setDownsampleEnabled(true)
                .build();
        Fresco.initialize(this, config);

        //初始化语言，默认为简体中文
        LangUtils.getAttachBaseContext(mContext);
        PrefUtils.setString(Constant.Language,"zh");

    }
}
